BACKGROUND:  This directory contains the code necessary to reproduce all the figures in the paper "Explaining Differences in Voting Patterns Across Voting Domains Using Hierarchical Bayesian Models" by Erin Lipman, Scott Moser and Abel Rodriguez, which is to appear in the journal Political Analysis.  The code implements the Markov chain Monte Carlo algorithm described in the paper to fit a hierarchical Bayesian model.To execute the code, open a terminal, go to the subfolder labeled "code" (see below), and type "./run_all.sh".   Before you do so, please ensure that the an up-to-date version of R (https://www.r-project.org/), along with the required packages (see below) are installed in your system. Compute time was approximately 27 hours in a 2.3 GHz 8-Core Intel Core i9 MacBook Pro with 32 GB of RAM running macOS 14.6.1.DIRECTORY STRUCTURE:  there are three main folders in this directorydata: contains 23 .RDS files.  21 of them contain the (preprocessed) voting data for the 93rd through 113rd US House of Representatives (they are labeled "inputs_H[XXX].RDS" where XXX stands for the House number).  The other two .RDS files contain covariates and party information.code:  the C++ code implementing the Markov chain Monte Carlo is located in the subfolder "src".  The bash script "run_all.sh" executes the following actions in turn:  (1) Launches 21 instances of R, each of which executes the code in "1_run_models.R" in parallel for each of the Houses in the dataset (2) Once posterior samples have been obtained for each House, 21 new instances of R running "2_postprocess.R" are launched to postprocess the results.   (3) "make_data_figures.R" is invoked to generate Figures 2 and 3 in the main paper (these figures rely only on the raw data). (4) "make_results_figures.R" generates Figure 1 and Figures 4 through 8 using the samples from the posterior distributions produced in steps 1 and 2 above, (5) another 21 instances of R
Executing "1_run_models.R" with slightly different setting (in particular, the flag "stage" 
is set to 1) to generate samples from a version of the model that does not include covariates,
(6) 21 instances of "2_postprocess.R" are launched to post processes the result, and (7) "make_supplement_figures.R" is invoked to generate the four figures in the supplement.results:  Once steps (1) and (2) above have been completed, the files containing the posterior samples for each House will be located here.  Once steps 3 and 4 are completed, .pdf files with each of the figures in the
paper will also be placed here.SOFTWARE REQUIRED:  The core of the Markov chain Monte Carlo algorithm is implemented in C++ and Fortran, with wrapper functions that call this code from within R.  R is also used to create all the plots presented in the paper.  In addition to the base R environment, you will need the following packages installed in your system:	require(yaml)	require(dplyr)	require(stringr)	require(tidyverse)	require(tidyr)	require(purrr)	require(ggplot2)	require(ggcorrplot)	require(scales)	require(forcats)	require(Rcpp)	require(RcppArmadillo)
	library(pscl)
	library(MCMCpack)
You will also need a universal GNU Fortran 12.2 compiler (or higher).  In case you are using macOS, you can find more information at  https://cran.r-project.org/bin/macosx/tools/ 